<%
layout("/include/_dialog.html"){
%>
	<script type="text/javascript">
        function save() {
            var isValidate = jp.validateForm('#inputForm');//校验表单
            if(!isValidate){
                return false;
            }else{
                jp.loading();
                jp.post("${ctx}/sys/role/save",$('#inputForm').serialize(),function(data){
                    if(data.success){
                        jp.getParent().refresh();
                        var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                        parent.layer.close(dialogIndex);
                        jp.success(data.msg)

                    }else{
                        jp.error(data.msg);
                    }
                })
            }

        }

		$(document).ready(function(){
			$("#name").focus();
			$("#inputForm").validate({
				rules: {
					name: {remote: "${ctx}/sys/role/checkName?oldName=" + encodeURIComponent("${role.name}")},//设置了远程验证，在初始化时必须预先调用一次。
					enname: {remote: "${ctx}/sys/role/checkEnname?oldEnname=" + encodeURIComponent("${role.enname}")}
				},
				messages: {
					name: {remote: "角色名已存在"},
					enname: {remote: "英文名已存在"}
				}
			});
		});

	</script>
	<form id="inputForm" action="${ctx}/sys/role/save" method="post" class="form-horizontal p-15" >
		<input type="hidden" name="id" value="${role.id!}">
		<table class="table table-bordered">
		   <tbody>
		      <tr>
		         <td class="width-15 active"><label class="pull-right">归属机构:</label></td>
		         <td class="width-35">
					 <#treeselect id="office" name="office.id" value="${role.office.id!}" labelName="office.name" labelValue="${role.office.name!}"
					 title="机构" url="/sys/office/treeData" allowClear="true" class="form-control required"/></td>
		         <td  class="width-15 active" class="active"><label class="pull-right"><font color="red">*</font>角色名称:</label></td>
		         <td class="width-35">
					 <input id="oldName" name="oldName" type="hidden" value="${role.name!}">
					 <input name="name" value="${role.name!}" maxlength="50" class="form-control required"/>
				 </td>
		      </tr>
		      <tr>
		         <td class="width-15 active"><label class="pull-right"><font color="red">*</font>英文名称:</label></td>
		         <td class="width-35">
					 <input id="oldEnname" name="oldEnname" type="hidden" value="${role.enname!}">
					 <input name="enname" value="${role.enname!}" maxlength="50" class="form-control required"/>
				 </td>
		         <td  class="width-15 active" class="active"><label class="pull-right">角色类型:</label></td>
		         <td class="width-35">
					 <select name="roleType" class="form-control ">
						 <option class="form-control" value="assignment" ${role.roleType! =="assignment"?"selected":""}>任务分配</option>
						 <option class="form-control" value="security-role" ${role.roleType! =="security-role"?"selected":""}>管理角色</option>
						 <option class="form-control" value="user" ${role.roleType! =="user"?"selected":""}>普通角色</option>
					 </select>


					<span class="text-muted" title="activiti有3种预定义的组类型：security-role、assignment、user 如果使用Activiti Explorer，需要security-role才能看到manage页签，需要assignment才能claim任务">
						<small>工作流组用户组类型（任务分配：assignment、管理角色：security-role、普通角色：user）</small>
					</span>
				 </td>
		      </tr>
		      <tr>
		         <td class="width-15 active"><label class="pull-right">是否系统数据:</label></td>
		         <td class="width-35">
					 <#select path="sysData" value="${role.sysData!}" items="${fn.getDictList('yes_no')}" itemLabel="label" itemValue="value" class="form-control "/>
					 <span class="text-muted">
						 <small>“是”代表此数据只有超级管理员能进行修改，“否”则表示拥有角色修改人员的权限都能进行修改</small>
					 </span>
				 </td>
		         <td  class="width-15 active"><label class="pull-right">是否可用</label></td>
		         <td class="width-35">
					 <#select path="useable" value="${role.useable!}" items="${fn.getDictList('yes_no')}" itemLabel="label" itemValue="value" class="form-control " />
					 <span class="text-muted"><small>“是”代表此数据可用，“否”则表示此数据不可用</small></span></td>
		      </tr>
		      <tr>
				 <td class="width-15 active"><label class="pull-right">备注:</label></td>
		         <td class="width-35">
					 <textarea name="remarks"  rows="3" maxlength="200" class="form-control ">${role.remarks!}</textarea>
				 </td>
		          <td class="width-15 active"></td>
		         <td class="width-35"></td>
		      </tr>
			</tbody>
			</table>
			<input type="hidden" name="menuIds" value="${role.menuIds!}">
	</form>
<% } %>